import os
import requests

url = "https://images-assets.nasa.gov/image/GSFC_20171208_Archive_e001921/GSFC_20171208_Archive_e001921~orig.jpg"
save_dir = f"D:/230320203002/"      # 替换实际学号
os.makedirs(save_dir, exist_ok=True)

response = requests.get(url, stream=True)
if response.status_code == 200:
    filename = os.path.join(save_dir, "230320203002.jpg")  # 同样替换学号
    with open(filename, 'wb') as f:
        for chunk in response.iter_content(1024 * 8):
            f.write(chunk)
    print(f"图片已保存至：{filename}")
else:
    print("下载失败，状态码：", response.status_code)